home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / volume / VOLUMES5.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1998-09-27  |  7.9 KB  |  254 lines

  1. VERSION 5.00
  2. Object = "{C15FC429-0D33-11D2-B6C8-0060976C699F}#1.1#0"; "MVolume.ocx"
  3. Begin VB.Form Form1 
  4.    BorderStyle     =   1  'Fixed Single
  5.    Caption         =   "Mabry Volume Sample"
  6.    ClientHeight    =   2850
  7.    ClientLeft      =   4755
  8.    ClientTop       =   2340
  9.    ClientWidth     =   3135
  10.    LinkTopic       =   "Form1"
  11.    MaxButton       =   0   'False
  12.    MinButton       =   0   'False
  13.    PaletteMode     =   1  'UseZOrder
  14.    ScaleHeight     =   2850
  15.    ScaleWidth      =   3135
  16.    StartUpPosition =   2  'CenterScreen
  17.    Begin VB.CommandButton Command2 
  18.       Caption         =   "Refresh"
  19.       Height          =   375
  20.       Left            =   840
  21.       TabIndex        =   6
  22.       Top             =   2400
  23.       Width           =   1335
  24.    End
  25.    Begin VB.Timer Timer1 
  26.       Enabled         =   0   'False
  27.       Interval        =   500
  28.       Left            =   120
  29.       Top             =   960
  30.    End
  31.    Begin VB.CommandButton Command1 
  32.       Caption         =   "Start Beeps"
  33.       Default         =   -1  'True
  34.       Height          =   375
  35.       Left            =   840
  36.       TabIndex        =   0
  37.       Top             =   2040
  38.       Width           =   1335
  39.    End
  40.    Begin VB.CheckBox chkLock 
  41.       Caption         =   "Lock Channels"
  42.       Height          =   255
  43.       Left            =   840
  44.       TabIndex        =   3
  45.       Top             =   1560
  46.       Width           =   1455
  47.    End
  48.    Begin VB.CheckBox chkMuteRight 
  49.       Caption         =   "Mute Right"
  50.       Height          =   255
  51.       Left            =   840
  52.       TabIndex        =   2
  53.       Top             =   1200
  54.       Width           =   1215
  55.    End
  56.    Begin VB.CheckBox chkMuteLeft 
  57.       Caption         =   "Mute Left"
  58.       Height          =   255
  59.       Left            =   840
  60.       TabIndex        =   1
  61.       Top             =   960
  62.       Width           =   1215
  63.    End
  64.    Begin VB.VScrollBar vscrRight 
  65.       Height          =   1815
  66.       LargeChange     =   100
  67.       Left            =   2760
  68.       Max             =   0
  69.       Min             =   32767
  70.       TabIndex        =   5
  71.       Top             =   240
  72.       Width           =   255
  73.    End
  74.    Begin VB.VScrollBar vscrLeft 
  75.       Height          =   1815
  76.       LargeChange     =   100
  77.       Left            =   2400
  78.       Max             =   0
  79.       Min             =   32767
  80.       TabIndex        =   4
  81.       Top             =   240
  82.       Width           =   255
  83.    End
  84.    Begin VolumeControl.MVolume MVolume1 
  85.       Left            =   120
  86.       Top             =   1440
  87.       _ExtentX        =   847
  88.       _ExtentY        =   847
  89.    End
  90.    Begin VB.Label Label6 
  91.       Alignment       =   2  'Center
  92.       Caption         =   "Min"
  93.       Height          =   255
  94.       Left            =   2400
  95.       TabIndex        =   12
  96.       Top             =   2160
  97.       Width           =   495
  98.    End
  99.    Begin VB.Label Label5 
  100.       Alignment       =   2  'Center
  101.       Caption         =   "Max"
  102.       Height          =   255
  103.       Left            =   2400
  104.       TabIndex        =   11
  105.       Top             =   0
  106.       Width           =   495
  107.    End
  108.    Begin VB.Label lblRight 
  109.       Height          =   255
  110.       Left            =   840
  111.       TabIndex        =   10
  112.       Top             =   480
  113.       Width           =   1335
  114.    End
  115.    Begin VB.Label lblLeft 
  116.       Height          =   255
  117.       Left            =   840
  118.       TabIndex        =   9
  119.       Top             =   120
  120.       Width           =   1335
  121.    End
  122.    Begin VB.Label Label2 
  123.       Alignment       =   1  'Right Justify
  124.       Caption         =   "Right:"
  125.       Height          =   255
  126.       Left            =   120
  127.       TabIndex        =   8
  128.       Top             =   480
  129.       Width           =   615
  130.    End
  131.    Begin VB.Label Label1 
  132.       Alignment       =   1  'Right Justify
  133.       Caption         =   "Left:"
  134.       Height          =   255
  135.       Left            =   120
  136.       TabIndex        =   7
  137.       Top             =   120
  138.       Width           =   615
  139.    End
  140. Attribute VB_Name = "Form1"
  141. Attribute VB_GlobalNameSpace = False
  142. Attribute VB_Creatable = False
  143. Attribute VB_PredeclaredId = True
  144. Attribute VB_Exposed = False
  145. Option Explicit
  146. Private fLocked As Boolean
  147. Private Sub chkLock_Click()
  148.     If chkLock.Value = vbChecked Then
  149.         fLocked = True
  150.     Else
  151.         fLocked = False
  152.     End If
  153. End Sub
  154. Private Sub chkMuteLeft_Click()
  155.     If chkMuteLeft.Value = vbChecked Then
  156.         MVolume1.MuteLeft = True
  157.     Else
  158.         MVolume1.MuteLeft = False
  159.     End If
  160. End Sub
  161. Private Sub chkMuteRight_Click()
  162.     If chkMuteRight.Value = vbChecked Then
  163.         MVolume1.MuteRight = True
  164.     Else
  165.         MVolume1.MuteRight = False
  166.     End If
  167. End Sub
  168. Private Sub Command1_Click()
  169.     If Timer1.Enabled = False Then
  170.         Timer1.Enabled = True
  171.         Command1.Caption = "Stop Beeps"
  172.     Else
  173.         Timer1.Enabled = False
  174.         Command1.Caption = "Start Beeps"
  175.     End If
  176. End Sub
  177. Private Sub Command2_Click()
  178.     '
  179.     'if you change the volume from the
  180.     'Windows Speaker applet, you can detect
  181.     'the change after invoking the Refresh
  182.     'method.
  183.     '
  184.     'Please note that the Volume control supports
  185.     'the full range of signed integer values (&H0000 thru &HFFFF)
  186.     'but the sample only supports &H0000 thru &H7FFF so the
  187.     'scrollbars could easily track the volume in a linear fashion.
  188.     'If you use the Windows volume applet to change the volume to
  189.     '&H8000 or above, an invalid property setting error will occur
  190.     'because this is outside of the range of the scroll bars.
  191.     '
  192.     'see the Form_Load event for details on trapping this in this
  193.     'sample. To use the entire range, extra code would be necessary
  194.     'to make the scroll bars behave in a linear fashion.
  195.     MVolume1.Refresh
  196.     vscrLeft.Value = MVolume1.VolumeLeft
  197.     vscrRight.Value = MVolume1.VolumeRight
  198.     lblLeft.Caption = Hex$(MVolume1.VolumeLeft)
  199.     lblRight.Caption = Hex$(MVolume1.VolumeRight)
  200. End Sub
  201. Private Sub Form_Load()
  202.     'the system and the Volume control tracks the volume levels
  203.     'using a range of &H0000 to &HFFFF. The sample uses
  204.     'Scrollbars to adjust the range in a linear fashion, but
  205.     'when the upper bit is set (ie -- above &H7FFF) the
  206.     'linear effect of the scrollbars is lost. So, although
  207.     'the control is capable of supporting the entire range of
  208.     '&H0 to &HFFFF, the sample only demonstrates a range of
  209.     '&H0 to &H7FFF so the Scrollbars could be easily used.
  210.     '
  211.     'The following statements trap values greater than &H7FFF
  212.     If MVolume1.VolumeLeft < 0 Then
  213.         MVolume1.VolumeLeft = &H7FFF
  214.     End If
  215.     If MVolume1.VolumeRight < 0 Then
  216.         MVolume1.VolumeRight = &H7FFF
  217.     End If
  218.     vscrLeft.Value = MVolume1.VolumeLeft
  219.     vscrRight.Value = MVolume1.VolumeRight
  220.     lblLeft.Caption = Hex$(MVolume1.VolumeLeft)
  221.     lblRight.Caption = Hex$(MVolume1.VolumeRight)
  222. End Sub
  223. Private Sub Timer1_Timer()
  224.     Beep
  225. End Sub
  226. Private Sub vscrLeft_Change()
  227.     MVolume1.VolumeLeft = vscrLeft.Value
  228.     If fLocked = True Then
  229.         vscrRight.Value = vscrLeft.Value
  230.     End If
  231.     lblLeft.Caption = Hex$(MVolume1.VolumeLeft)
  232. End Sub
  233. Private Sub vscrLeft_Scroll()
  234.     MVolume1.VolumeLeft = vscrLeft.Value
  235.     If fLocked = True Then
  236.         vscrRight.Value = vscrLeft.Value
  237.     End If
  238.     lblLeft.Caption = Hex$(MVolume1.VolumeLeft)
  239. End Sub
  240. Private Sub vscrRight_Change()
  241.     MVolume1.VolumeRight = vscrRight.Value
  242.     If fLocked = True Then
  243.         vscrLeft.Value = vscrRight.Value
  244.     End If
  245.     lblRight.Caption = Hex$(MVolume1.VolumeRight)
  246. End Sub
  247. Private Sub vscrRight_Scroll()
  248.     MVolume1.VolumeRight = vscrRight.Value
  249.     If fLocked = True Then
  250.         vscrLeft.Value = vscrRight.Value
  251.     End If
  252.     lblRight.Caption = Hex$(MVolume1.VolumeRight)
  253. End Sub
  254.